<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>p2_CSS选择器</title>
    <style>
        h4{
            color: red;
        }
        div{
            width: 100px;
            height: 100px;
            background-color: cyan;
        }
        #d2{
            border: 5px solid black;
        }
        .error{
            background-color: red;
        }
        .success{
            background-color: green;
        }
        .msg{
            color: white;
        }
        /*伪类选择器，hover悬停状态*/
        #d2:hover{
            background-color: yellow;
        }
        /*群组选择器，逗号隔开，是或的关系，满足一个即可*/
        #d2,h4,error{
            text-decoration: underline;
        }
        /*选中所有*/
        *{
            font-style: italic;/*文字斜体*/
        }
        a:link{
            color: gray;
        }
        a:visited{
            color: green;
        }
        a:hover{
            color: orange;
        }
        a:active{
            color: red;
        }
        /*属性选择器[]加属性*/
        [type="text"]{
            background-color: yellow;
        }
        div span{
            color: orange;
        }
        #d1>div>span{
            color: red;
        }
    </style>
</head>
<body>
<div id="d1">
    <span>1</span>
    <div>
        <span>2</span>
        <b>测试文字</b>
        <p>我是<span>测试</span>段落</p>
    </div>
    <span>3</span>
</div>

<input type="text">
<input type="password">
<a href="https://www.baidu.com">我是百度</a>
<a href="https://www.baidu132456.com">我不是百度</a>
<h4>我是标题</h4>
<p>我是段落</p>
<a href="#">我是超链接</a>
<h4 id="d2">我是标题2</h4>
<div>我是div1</div>
<div>我是div2</div>
<div>我是div3</div>
<hr>
<span class="error msg">用户名被占用</span>
<span class="error msg">密码长度错误</span>
<span class="error msg">手机号格式错误</span>

<span class="success msg">用户名可以使用</span>
<span class="success msg">两次密码一致</span>
<span class="success msg">手机号格式正确</span>
</body>
</html>